<!DOCTYPE html>
<html lang="en" class="bg-dark">
<head>
    <meta charset="utf-8" />
    <title>Backstage-signin</title>
    <#assign bathPath="${springMacroRequestContext.getContextPath()}" >
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="stylesheet" href="${bathPath}/static/mystatic/css/app.v2.css" type="text/css" />
    <!--[if lt IE 9]> <script src="${bathPath}/static/mystatic/js/ie/html5shiv.js" cache="false"></script>
<script src="${bathPath}/static/mystatic/js/ie/respond.min.js" cache="false"></script>
<script src="${bathPath}/static/mystatic/js/ie/excanvas.js" cache="false"></script> <![endif]-->
    <style>
        span.help-block{
            text-align: center;
            color: red;
        }
    </style>
</head>
<body>
<section id="content" class="m-t-lg wrapper-md animated fadeInUp">
    <div class="container aside-xxl"> <a class="navbar-brand block" href="index.html">基本粒子产品管理</a>
        <section class="panel panel-default bg-white m-t-lg">
            <header class="panel-heading text-center"> <strong>账密登录</strong> </header>
            <form id="userForm" class="panel-body wrapper-lg">
                <div class="form-group">
                    <label class="control-label">账号</label>
                    <input type="text" placeholder="请输入账号" id="userName" name="userName" class="form-control input-lg required">
                </div>
                <div class="form-group">
                    <label class="control-label">密码</label>
                    <input type="password" id="pwd" name="pwd" placeholder="请输入密码" class="form-control input-lg required">
                </div>
                <div class="line line-dashed"></div>
                <!--<a id="loginBtn" href="#" class="btn btn-facebook btn-block m-b-sm">第三方登录</a>-->
                <button type="submit" class="btn btn-facebook btn-block m-b-sm">登录</button>
                <a href="${bathPath}/regist">注册账号</a>
            </form>
        </section>
    </div>
</section>
<!-- footer -->
<!--footer不用可以隐藏！！！！-->
<footer id="footer">
    <div class="text-center padder">
        <p> <small>This is Copyright</small> </p>
    </div>
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="${bathPath}/static/mystatic/js/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="${bathPath}/static/mystatic/lib/bootstrap-3.3.7/js/bootstrap.min.js"></script>
<script src="${bathPath}/static/mystatic/js/jquery.validate.js"></script>
<script src="${bathPath}/static/mystatic/layui/js/layer.js"></script>


<script type="text/javascript">
    $.validator.setDefaults({
        submitHandler: function() {
            var loading_div_index=0;
            $.ajax({
                    url: '${bathPath}/login_manager/login_in',
                    type: 'post',
                    timeout: 30000,
                    data: $("#userForm").serialize(),
                    beforeSend:function () {
                        loading_div_index = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
                    },
                    success: function (result) {
                        if(0==result.error){
                            window.location.href="${bathPath}/list";

                        }else{
                            layer.alert(result.msg, {icon: 2});
                        }

                    },
                    error: function (MLHttpRequest, textStatus) {
                        if (MLHttpRequest.status == '502') {
                            layer.alert('服务已关闭!', {icon: 5})
                        } else if (MLHttpRequest.status == '504') {
                            layer.alert('服务请求超时！', {icon: 5})
                        }
                    },
                    complete:function () {
                        layer.close(loading_div_index);
                    }
                }
            );
        }
    });
    $().ready(function() {
        $("#userForm").validate(
            {
                errorElement : 'span',
                errorClass : 'help-block',
                messages : {
                    userName : {
                        required : "请输入账号",
                    },
                    pwd : {
                        required : "请输入密码",
                        minlength : jQuery.format("密码不能小于{0}个字 符")
                    }
                }
            }
        );
    });

    
</script>
</body>
</html>
